package com.ruoyi.demo.service.base.impl;

import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.commons.lang3.StringUtils;
import com.ruoyi.demo.mapper.DemoGoodsMapper;
import com.ruoyi.demo.domain.DemoGoods;
import com.ruoyi.demo.service.base.DemoGoodsService;

import java.util.List;

/**
 * 商品Service业务层处理
 *
 * @author zhangshu
 * @date 2021-02-02
 */
@Service
public class DemoGoodsServiceImpl extends ServiceImpl<DemoGoodsMapper, DemoGoods> implements DemoGoodsService {

    @Override
    public List<DemoGoods> queryList(DemoGoods demoGoods) {
        LambdaQueryWrapper<DemoGoods> lqw = Wrappers.lambdaQuery();
        if (demoGoods.getCustomerId() != null){
            lqw.eq(DemoGoods::getCustomerId ,demoGoods.getCustomerId());
        }
        if (StringUtils.isNotBlank(demoGoods.getName())){
            lqw.like(DemoGoods::getName ,demoGoods.getName());
        }
        if (demoGoods.getWeight() != null){
            lqw.eq(DemoGoods::getWeight ,demoGoods.getWeight());
        }
        if (demoGoods.getPrice() != null){
            lqw.eq(DemoGoods::getPrice ,demoGoods.getPrice());
        }
        if (demoGoods.getDate() != null){
            lqw.eq(DemoGoods::getDate ,demoGoods.getDate());
        }
        if (StringUtils.isNotBlank(demoGoods.getType())){
            lqw.eq(DemoGoods::getType ,demoGoods.getType());
        }
        return this.list(lqw);
    }
}
